package netty.rpc.register;

import java.util.List;

/**
 * 注册
 * @author Jim
 * @version 1.0.0
 * @descripition:
 * @date 2022/5/21 16:21
 */
public interface Register {

    String SERVICE_PREFIX = "/services";

    String INSTANCE_PREFIX = "/instances";

    String PATH = "/simple-netty-rpc";

    /**
     * 注册  如果没有就创建
     * @param path 路径
     * @param value 值
     * @param isPersistent 是否持久化
     * @throws Exception
     */
    void registerPathIfNotExists(String path,String value,boolean isPersistent) throws Exception;

    /**
     * 创建目录
     * @param path
     * @param isPersistent
     */
    void createDirector(String path,boolean isPersistent) throws Exception;

    /**
     * 获取子节点目录
     * @param path
     * @return
     */
    List<String> getChildrenDirectors(String path) throws Exception;

    /**
     * 注册临时节点
     * @param path
     * @param value
     * @return
     * @throws Exception
     */
    boolean registerEphemeralNode(String path,String value) throws Exception;

    /**
     * 注册临时节点
     * @param path
     * @return
     * @throws Exception
     */
    boolean registerEphemeralNode(String path) throws Exception;

    /**
     * 注册持久化节点
     * @param path
     * @param value
     * @return
     * @throws Exception
     */
    boolean registerPersistentNode(String path,String value) throws Exception;

    /**
     * 启用服务
     */
    void enableService(String serviceName) throws Exception;

    /**
     * 关闭服务
     */
    void unableService(String serviceName) throws Exception;

    /**
     * 启用服务 指定接口
     * @param serviceName
     * @param interfaceName
     */
    void enableServiceInterface(String serviceName,String interfaceName) throws Exception;


    /**
     * 关闭服务 指定接口
     * @param serviceName
     * @param interfaceName
     * @throws Exception
     */
    void unableServiceInterface(String serviceName,String interfaceName) throws Exception;

}
